<%@ include file="/en/jsp/static.jsp" %>

<%@ page import="linuxbox.poll.logic.*,linuxbox.bean.*" %>
<%@ page import="linuxbox.util.WebTools" %>

<%@ taglib uri="/linuxbox/Poll.tld" prefix="poll" %>
<%

  String SUBJECT = (String)request.getAttribute("SUBJECT");
  String DESCRIPTION = (String)request.getAttribute("DESCRIPTION");
  boolean SHOWRESULT = Integer.parseInt((String)request.getAttribute("SHOWRESULT")) != 0;
  boolean MULTIPLE = Integer.parseInt((String)request.getAttribute("MULTIPLE")) != 0;
  boolean VIEWONLY = Integer.parseInt((String)request.getAttribute("VIEWONLY")) != 0;

  boolean SHOWVOTER = (Integer.parseInt((String)request.getAttribute("SHOWVOTER"))!=0);

  //TODO: check user rights to adjust SHOWRESULT,SHOWVOTER
  SHOWRESULT = SHOWRESULT || sec.isPollAdmin();
  SHOWVOTER = SHOWVOTER || sec.isPollAdmin();

  int ID = Integer.parseInt((String)request.getAttribute("ID"));

  String PERCENTIMAGE =BoxStatic.imageDir+ "bluedot.gif";
  BoxPoll home = new BoxPoll();
  String CHOICETYPE = "radio";
  if (MULTIPLE)
    CHOICETYPE = "checkbox";
%>
<jsp:include page="/en/jsp/header.jsp" flush="true"/>


<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
<tr><td>
    &nbsp;<img src="<%=BoxStatic.imageDir%>itemball.jpg" width=14 height=15 border=0 align="absmiddle">
    <b><%=boxName%> - Poll Vote</b>
</td></tr>
</table>

<hr width=\"100%\" color=#E06000 align=left>


<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td>

<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
  <TBODY>
  <TR align=left bgColor=#7EC1F3>
    <TD noWrap><B><font size="+1">Question</FONT></B>
    </TD>
  </TR>
  <TR><TD>
    <b><%=SUBJECT%></b>
  </TD></TR>
  <TR><TD>
    <FONT size=-1><%=DESCRIPTION%></FONT>
  </TD></TR>
<%
  if (!VIEWONLY)
  {
%>
  <TR align=left>
    <FORM action=<%=BoxStatic.servletDir%>BoxPollVoteAction method=post>
    <INPUT type=hidden value=<%=ID%> name=ID>
    <TD>
      <TABLE cellSpacing=0 cellPadding=2 border=0>
        <TBODY>
          <poll:MyVotes userID="<%=curID%>" pollID="<%=ID%>" choiceType="<%=CHOICETYPE%>"/>
        </TBODY>
      </TABLE>
    </TD>
  </TR>
  <TR align=left>
    <TD>
      <FONT size=-1>
        <INPUT type=submit value=Vote name=SubmitVote>
        <input type=button value="Close" onclick="window.history.go(-1)" >
      </FONT>
    </TD>
  </TR>
  <TR align=left>
    <TD><FONT size=-1>Your vote is shown above. You can change your vote until the poll is concluded. </FONT>
    </TD>
  </TR>
  <TR align=left>
    <TD>&nbsp;</TD>
  </TR>
  </FORM>

<%
  }

  if ( SHOWRESULT )
  {
%>
    <TR align=left bgColor=#7EC1F3>
      <TD noWrap><B><font size="+1">Responses</font></B></TD>
    </TR>
    <TR><TD>
      <TABLE cellSpacing=0 cellPadding=2 border=0>
      <TBODY>
        <poll:VoteResults pollID="<%=ID%>" showVoter="<%=Boolean.toString(SHOWVOTER)%>" percentImage="<%=PERCENTIMAGE%>" />
      </TBODY>
      </TABLE>
    </TD>
    </TR>
<%
  }
  else
  {
    out.print("<TR><TD>Results are hidden until polling is over.</TD><TR>");
  }
%>

  </TBODY>
</TABLE>

</td></tr>
</table>

<hr width=\"100%\" color=#E06000 align=left>

<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
